#pragma once
#include <QPlainTextEdit>
#include <QTextCursor>
#include <QChar>

class ChatWidget : public QPlainTextEdit
{
    Q_OBJECT
public:
    ChatWidget(QWidget *parent = 0);
signals:
    void finishedMsg();
    void typedChar(QChar msg);
    void typedString(QString msg);
    void typedBackspace();
    void typedDelete();
    void moveCursor(qint16 dir);

public slots:
    void remoteWrite(QString text);
    void remoteWrite(QChar msg);
    void remoteBackspace();
    void remoteFinish();
private slots:
    void demoRemoteMessage();
    void localFinish();
    void cursorMoved();
protected:
    void insertFromMimeData (const QMimeData * source);
private:
    void keyPressEvent(QKeyEvent *event);

    int posForNextFinishedMsg;

    QTextCursor *remoteCursor;
    //int posRemoteStart;

    QTextCursor *localCursor;

    QString remoteTag;
    QString localTag;

    //TODO: remove, debug var
    int x;
};
